package org.seeplnframework.skyeye.common.model;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

@EqualsAndHashCode(callSuper = true)
@Data
public class WechatMarkDownMessage extends WechatMessage implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 消息类型
     */
    private String msgType = "markdown";

    /**
     * Text
     */
    private Text markdown;

    /**
     * 指定该消息要推送的群地址
     */
    private String targetHook = "";

    /**
     * 当前消息是否属于业务错误报警提示
     */
    private boolean businessReminder = false;

    @Data
    public static class Text {

        /**
         * 消息内容
         */
        private String content;
    }

    @Override
    public String toString() {
        JSONObject markdownT = new JSONObject();
        markdownT.put("content", this.getMarkdown().getContent());
        JSONObject json = new JSONObject();
        json.put("msgtype", this.getMsgType());
        json.put("markdown", markdownT);
        return JSONUtil.toJsonStr(json);
    }
}
